﻿<%@ Page Language="C#" MasterPageFile="../main.master" Inherits="VioletDevelopmentLaboratory.Net.Web.Configuration.VWebConfigManagerPage" %>

<script runat="server">
	protected void UrlMappingsDetailsView_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
	{
		ShowAlert_DetailsView_ItemUpdated(e);
	}










	protected void UrlMappingGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
	{
		UrlMappingDetailsView.ChangeMode(DetailsViewMode.ReadOnly);
	}
	protected void UrlMappingDetailsView_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
	{
		ShowAlert_DetailsView_ItemInserted(e);

		UrlMappingGridView.SelectedIndex = -1;
		UrlMappingGridView.DataBind();
	}
	protected void UrlMappingDetailsView_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
	{
		ShowAlert_DetailsView_ItemDeleted(e);

		UrlMappingDetailsView.ChangeMode(DetailsViewMode.Insert);
		
		UrlMappingGridView.SelectedIndex = -1;
		UrlMappingGridView.DataBind();
	}
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">

	<h2>UrlMappings</h2>

	<div>
		<asp:ObjectDataSource ID="UrlMappingsDetailsViewDataSource" runat="server" 
			SelectMethod="GetUrlMappingsSection" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.UrlMappingsSectionManager" 
			UpdateMethod="Modify">
			<UpdateParameters>
				<asp:Parameter Name="isEnabled" Type="Boolean" />
			</UpdateParameters>
		</asp:ObjectDataSource>
		<fieldset>
			<asp:DetailsView ID="UrlMappingsDetailsView" runat="server" 
				AutoGenerateRows="False" CellPadding="5" 
				DataSourceID="UrlMappingsDetailsViewDataSource" DefaultMode="Edit" 
				onitemupdated="UrlMappingsDetailsView_ItemUpdated">
				<Fields>
					<asp:CheckBoxField DataField="IsEnabled" HeaderText="IsEnabled" 
						SortExpression="IsEnabled" />
					<asp:CommandField ButtonType="Button" ShowCancelButton="False" 
						ShowEditButton="True" />
				</Fields>
			</asp:DetailsView>
		</fieldset>
	</div>

	<div style="margin-left : 30px">
		<asp:ObjectDataSource ID="UrlMappingDetailsViewDataSource" runat="server" 
			DeleteMethod="RemoveUrlMapping" InsertMethod="AddUrlMapping" 
			SelectMethod="GetUrlMapping" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.UrlMappingsSectionManager">
			<DeleteParameters>
				<asp:Parameter Name="url" Type="String" />
			</DeleteParameters>
			<SelectParameters>
				<asp:ControlParameter ControlID="UrlMappingGridView" Name="url" 
					PropertyName="SelectedValue" Type="String" />
			</SelectParameters>
			<InsertParameters>
				<asp:Parameter Name="url" Type="String" />
				<asp:Parameter Name="mappedUrl" Type="String" />
			</InsertParameters>
		</asp:ObjectDataSource>
		<asp:ObjectDataSource ID="UrlMappingGridViewDataSource" runat="server" 
			SelectMethod="GetUrlMappingCollection" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.UrlMappingsSectionManager"></asp:ObjectDataSource>
		<fieldset>
			<asp:DetailsView ID="UrlMappingDetailsView" runat="server" 
				AutoGenerateRows="False" CellPadding="5" DataKeyNames="Url" 
				DataSourceID="UrlMappingDetailsViewDataSource" DefaultMode="Insert" 
				oniteminserted="UrlMappingDetailsView_ItemInserted" 
				onitemdeleted="UrlMappingDetailsView_ItemDeleted">
				<Fields>
					<asp:BoundField DataField="Url" HeaderText="Url" ReadOnly="True" 
						SortExpression="Url" />
					<asp:BoundField DataField="MappedUrl" HeaderText="MappedUrl" ReadOnly="True" 
						SortExpression="MappedUrl" />
					<asp:CommandField ShowDeleteButton="True" ShowInsertButton="True" 
						ButtonType="Button" />
				</Fields>
			</asp:DetailsView>
			<asp:GridView ID="UrlMappingGridView" runat="server" 
				AutoGenerateColumns="False" CellPadding="5" DataKeyNames="Url" 
				DataSourceID="UrlMappingGridViewDataSource" 
				onselectedindexchanging="UrlMappingGridView_SelectedIndexChanging">
				<Columns>
					<asp:CommandField ShowSelectButton="True" />
					<asp:BoundField DataField="Url" HeaderText="Url" ReadOnly="True" 
						SortExpression="Url" />
					<asp:BoundField DataField="MappedUrl" HeaderText="MappedUrl" ReadOnly="True" 
						SortExpression="MappedUrl" />
				</Columns>
				<SelectedRowStyle BackColor="SkyBlue" />
			</asp:GridView>
		</fieldset>
	</div>
</asp:Content>